﻿using System;
using System.Collections.Generic;

using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MySql.Data.MySqlClient;
using System.Media;

namespace WebApplication3
{
    public partial class Login : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void ListBox1_SelectedIndexChanged(object sender, EventArgs e)
        {

        }

        protected void Button1_Click(object sender, EventArgs e)
        {
            try
            {
                string myConnectionString = "";

                // If the connection string is null, use a default.
                if (myConnectionString == "")
                {
                    myConnectionString = "Database=inventario;Data Source=localhost;User Id=root;Password=123";
                }

                MySqlConnection myConnection = new MySqlConnection(myConnectionString);
                string mySelectQuery = "SELECT nombre From empleados Where nombre= '" + TextBox2.Text+ "'&& contraseña='" + TextBox3.Text + "'";
                MySqlCommand myCommand = new MySqlCommand(mySelectQuery, myConnection);
                myConnection.Open();
                MySqlDataReader lectura;
                lectura = myCommand.ExecuteReader();

                if (lectura.Read() == true)
                {

                    //string sSelectedAudio = "c:\\welcome.wav";
                    //SoundPlayer objSoundPlayer = new SoundPlayer(sSelectedAudio);
                    //objSoundPlayer.Play();
                    
                    
                    
                    this.Label4.Text = "Datos Correctos Bienvenido";
                    Response.Redirect("Lista1.aspx");

                   
                
                }
                else
                {

                    this.Label4.Text = "Informacion Erronea, Vuelve Intentarlo";
                        
                    //string sSelectedAudio = "c:\\hasta_la_vista_baby.wav";
                    //SoundPlayer objSoundPlayer = new SoundPlayer(sSelectedAudio);
                    //objSoundPlayer.Play();




                }

                lectura.Close();
                myConnection.Close();
            }


                catch
            {
              
                    this.Label4.Text = "No hay conexión Error";
            }

        }
    }
}